package com.dream.banana.redis.lock;

import java.io.IOException;
import java.io.InputStream;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.FactoryBean;
/**
 * 躲了一辈子雨，雨会不会很难过。
 * </p>
 * Created by zhumenglong on 2017/5/28.
 */
public class LockClient implements FactoryBean<RedissonClient> {
    @Override
    public RedissonClient getObject() throws Exception {
        InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("lockConfig.yaml");
        Config config = Config.fromYAML(inputStream);
        config.setUseLinuxNativeEpoll(false);
        return Redisson.create(config);
    }

    @Override
    public Class<?> getObjectType() {
        return this.getClass();
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
